home *** CD-ROM | disk | FTP | other *** search
-
- #include "parms.h" /* added for proper prototyping -- EDB */
- /* Additions for prototypes -- EDB */
- #include "GraphicObject.h"
-
- #include "GraphicObjectClass.h"
- #include "OutlineBox.h"
- #include <stdlib.h>
- #include <string.h>
- #include "minmax.h"
- #include <graphics/gfxmacros.h>
- #ifndef __GNUC__
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/diskfont_protos.h>
- #endif
- #ifdef __GNUC__
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #include <proto/diskfont.h>
- #endif
- #ifdef __SASC
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #include <proto/diskfont.h>
- #endif
-
- #include "amigamem.h"
-
- Point OutlineBox_Location( OutlineBox *self )
- {
- return self->Location;
- }
-
-
- Point OutlineBox_SetLocation( OutlineBox *self,
- PIXELS LeftEdge,
- PIXELS TopEdge )
- {
- self->Location.x = LeftEdge;
- self->Location.y = TopEdge;
- return self->Location;
- }
-
- Point OutlineBox_Size( OutlineBox *self )
- {
- return self->Size;
- }
-
- Point OutlineBox_AskSize( OutlineBox *self,
- PIXELS Width,
- PIXELS Height )
- {
- Point size;
-
- size.x = MAX( Width, 6 );
- size.y = MAX( Height, 6 );
- return size;
- }
-
-
- Point OutlineBox_SetSize( OutlineBox *self,
- PIXELS Width,
- PIXELS Height )
- {
- Point size;
-
- size = AskSize( (GraphicObject *)self, Width, Height );
- self->Size.x = size.x;
- self->Size.y = size.y;
-
- pcg_Init3DThinBevel( &self->Bevel, 0, 0, size.x, size.y, 0,
- self->Pens.DarkPen, self->Pens.BrightPen, NULL );
-
- return size;
- }
-
-
- #define FONT_WIDTH 8
- #define FONT_HEIGHT 8
- #define BASELINE 7
-
- void OutlineBox_Render( OutlineBox *self,
- RastPort *RPort )
- {
- short width, length, x, y;
- Point location;
- Point size;
-
- /* Additions to correct font behavior under AmigaDOS 2.x/3.x -- EDB */
- TextAttr pcg_Topaz80 =
- { "topaz.font", TOPAZ_EIGHTY, FS_NORMAL, FPF_ROMFONT };
-
- struct TextFont *myfont, *oldfont;
-
- location = Location( (GraphicObject *)self );
- size = Size( (GraphicObject *)self );
- length = strlen(self->Label);
- width = length * FONT_WIDTH;
- x = location.x + size.x/2 - width/2;
- y = location.y - FONT_HEIGHT/2 + BASELINE;
-
- DrawBorder( RPort, (struct Border*) &self->Bevel, location.x, location.y );
-
- SetDrMd( RPort, JAM2 );
- SetAPen( RPort, self->Pens.FrontPen );
- SetBPen( RPort, self->Pens.BackPen );
- Move( RPort, x, y );
-
- /* Under 2.x/3.x Amiga OS we cannot presume the rastport default font is topaz */
- /* so we open it ourselves and close it when done -- EDB */
- if( myfont = OpenDiskFont( &pcg_Topaz80 ) )
- {
- oldfont = RPort->Font;
- SetFont( RPort, myfont );
- Text( RPort, self->Label, length );
- SetFont( RPort, oldfont );
- CloseFont( myfont );
- }
- }
-
- char *OutlineBox_Title( OutlineBox *self )
- {
- return self->Label;
- }
-
- BOOL OutlineBox_SetTitle( OutlineBox *self, char *title )
- {
- Afree( self->Label );
- self->Label = Astrdup(title);
- return TRUE;
- }
-
- #if 0 /* not ready for prime time */
- /* EDB -- Added Default Font Support Methods */
- extern TextAttr go_DefaultFont;
-
- TextAttr *OutlineBox_DefaultFont( OutlineBox *self )
- {
- if( self->LabelText.ITextFont != NULL )
- return self->LabelText.ITextFont;
- else return &go_DefaultFont; /* Topaz80 */
- }
-
- BOOL OutlineBox_SetDefaultFont( OutlineBox *self, TextAttr *default_font )
- {
- struct TextFont *myfont;
-
- if( default_font != NULL )
- { /* check to see if font is really available */
- if( myfont = OpenDiskFont( default_font ) )
- {
- self->LabelText.ITextFont = default_font;
-
- CloseFont( myfont );
- /* Get ourselves back into alignment */
- AlignText( &self->LabelText, Size( (GraphicObject *)self ) );
- return TRUE;
- }
- else return FALSE; /* font is not available */
- }
- else return FALSE; /* pointer was invalid */
- }
-
- #endif /* not ready for prime time */
-
- BOOL OutlineBox_elaborated = FALSE;
-
- struct GraphicObjectClass OutlineBox_Class;
-
-
- void OutlineBoxClass_Init( struct GraphicObjectClass *class )
- {
- GraphicObjectClass_Init( class );
- class->isa = GraphicObjectClass();
- class->ClassName = "OutlineBox";
- class->CleanUp = NULL;
- class->Location = (Point(*)(GraphicObject *))OutlineBox_Location;
- class->SetLocation = (Point(*)(GraphicObject *, PIXELS, PIXELS))OutlineBox_SetLocation;
- class->Size = (Point(*)(GraphicObject *))OutlineBox_Size;
- class->AskSize = (Point(*)(GraphicObject *, PIXELS, PIXELS))OutlineBox_AskSize;
- class->SetSize = (Point(*)(GraphicObject *, PIXELS, PIXELS))OutlineBox_SetSize;
- class->SizeFlags = GraphicObject_SizeFlagsAll;
- class->Render = (void(*)(GraphicObject *, RastPort *))OutlineBox_Render;
- class->SetTitle = (BOOL(*)(GraphicObject *, char *))OutlineBox_SetTitle;
- class->Title = (char*(*)(GraphicObject *))OutlineBox_Title;
-
- #if 0 /* not ready for primetime */
- /* EDB -- added default font methods */
- class->DefaultFont = OutlineBox_DefaultFont;
- class->SetDefaultFont = OutlineBox_SetDefaultFont;
- #endif
-
-
- }
-
-
- struct GraphicObjectClass *OutlineBoxClass( void )
- {
- if( ! OutlineBox_elaborated )
- {
- OutlineBoxClass_Init( &OutlineBox_Class );
- OutlineBox_elaborated = TRUE;
- }
-
- return &OutlineBox_Class;
- }
-
- void OutlineBox_Init( OutlineBox *self,
- PIXELS LeftEdge,
- PIXELS TopEdge,
- PIXELS Width,
- PIXELS Height,
- pcg_3DPens Pens,
- char *Label )
- {
- GraphicObject_Init( (GraphicObject *)self );
-
- self->isa = OutlineBoxClass();
- self->PObjectName = NULL;
- self->Label = NULL;
- self->Pens = Pens;
- SetLocation( (GraphicObject *)self, LeftEdge, TopEdge );
- SetSize( (GraphicObject *)self, Width, Height );
- SetTitle( (GraphicObject *)self, Label );
- }
-